package cn.tedu._05mvcboot01.controller;

import cn.tedu._05mvcboot01.pojo.dto.UserRegDto;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class UserController {
    @RequestMapping("v1/users/login")
    @ResponseBody
    public String login(){
        return "<h1>恭喜你，登录成功！</h1>";
    }

    @RequestMapping("v1/users/reg1")
    @ResponseBody
    public String register1(HttpServletRequest request){
        String username=request.getParameter("username");
        String password=request.getParameter("password");
        return "<h1>恭喜你，"+username+",注册成功！</h1><br/>请不要泄露你的密码:"+password;
    }

    @RequestMapping("v1/users/reg2")
    @ResponseBody
    public String reg2(String username,String password){
        return username+"---------"+password;
    }

    @RequestMapping("v1/users/reg3")
    @ResponseBody
    public String reg3(UserRegDto userRegDto){
        return userRegDto.getUsername()+"!!!!!!!!!!!!!!!"+userRegDto.getPassword();
    }
}
